<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>故障处理流程</title>
  <link href="css/layui.css" rel="stylesheet" type="text/css" />
  <link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="maintenance">
          <h3 class="title-row title_contents" id="title_content"></h3>
          <form class="layui-form" action="">
            <div class="layui-form-item layui-form-text textBox">
              <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-input-block sumitBtn">
            <button class="layui-btn confirmButton" lay-submit lay-filter="formDemo" type="button">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary closePage" type="button">取消</button>
          </div>
        </div>
        </form>
      </div>
    </div>
  </div>
  <script src="layui.js"></script>
  <script src="index.js"></script>
  <script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'form', 'table'], function () {
      var layer = layui.layer
        , $ = layui.$
        , table = layui.table //表格
        , form = layui.form;

      var paramData = getFlowData();
      // console.log(paramData);

      $('.closePage').on('click', function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当前页
      })


      layer.ready(function () {
        //进入页面即查询抢修方案  有则展示
        generateTextArea();  
      });


      $('.confirmButton').on('click', function (data) {
        var planDesc = $("[name='desc']").val();
        if (planDesc.length < 1) {
          alertMsg('请填写抢救方案！');
          return;
        }

        var paramDatas = {
          faultId: paramData.faultId,
          tag: paramData.tag,
          flowLinkId: getValue("flowLinkId"),
          projectText: planDesc
        }

        // console.log(paramDatas);
        $.ajax({
          url: getIP()+'/flowLink/addRepairPlan',
          type: 'post',
          data: paramDatas,
          contentType: 'application/x-www-form-urlencoded',
          success: function (data) {
            if (data.code == 'success') {
              layer.msg(data.msg, { time: 700, icon: 6 }, function () {
                closeSonPage();
              });//失败的表情5 成功的表情6
              return;
            }else{
              layer.msg(data.msg, { time: 700, icon: 5 }, function () {
                closeSonPage();
              });//失败的表情5 成功的表情6
            }
          },
          complete: function () {
            // layer.close(this.layerIndex);

          },
        });

      });


      function generateTextArea() {
        $.ajax({
          url: getIP()+'/flowLink/queryRepairPlan',
          type: 'post',
          data: { faultId: paramData.faultId, tag: paramData.tag,flowLinkId: getValue("flowLinkId") },
          contentType: 'application/x-www-form-urlencoded',
          success: function (data) {
            if (data.code == 'success') {
              $("[name='desc']").val(data.msg)
            }
          },
          complete: function () {
            // layer.close(this.layerIndex);

          },
        });

      }

    });
  </script>
</body>

</html>